package com.yyg.boot.web;

import com.yyg.boot.entity.User;
import com.yyg.boot.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Author 一一哥Sun
 * @Date Created in 2020/4/29
 * @Description Description
 */
@RestController
@RequestMapping("/user")
public class UserController {

    @Autowired
    private UserService userService;

    /**
     * save user
     */
    @PostMapping(value = "/save")
    public User save(@RequestBody User user) {
        return userService.saveUser(user);
    }

    /**
     * find user by username
     */
    @GetMapping(value = "/{username}")
    public User findUser(@PathVariable String username) {
        return userService.findByUsername(username);
    }

}
